<%@ include file="/WEB-INF/views/commonJSTL.jsp" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>


<fmt:message key="form.selected" var="selected"/>	
<c:set var="selectedUnit" value="4" />
<c:set var="selectedPackage" value="1" />

<c:set var="tempPriceTotal"/>
<c:set var="tempPriceTotalDcto"/>
<c:if test="${pharmacyProduct.pharmacyproductPK.productId != ''}">
	<c:choose>
		<c:when test="${pharmacyProduct.package1}">
			<c:set var="tempPriceTotal" value="${pharmacyProduct.cost * pharmacyProduct.valueTempCountPackage}" />
			<c:set var="tempPriceTotalDcto" value="${tempPriceTotal*((100-pharmacyProduct.valueDiscount)/100)}" />
		</c:when>
		<c:otherwise>
			<c:set var="tempPriceTotal" value="${pharmacyProduct.cost * pharmacyProduct.valueTempCountItem}" />
			<c:set var="tempPriceTotalDcto" value="${tempPriceTotal*((100-pharmacyProduct.valueDiscount)/100)}" />
		</c:otherwise>
	</c:choose>
	
</c:if>


<script type="text/javascript">
	$(document).ready(function(){	
		$("#nameProviderContainer").html('<b><label>${provider.name}</label></b>');
		requiresPrescription();
		purchaseUnit();
		//showPercentage1();
		//showPercentage2();
		$("input[name='_purchaseUnit']").change(function(){
			purchaseUnit();
			$("#_discount").val(0);
			$("#_priceTotalDcto").val('');
			$("#_priceTotal").val('');
			$("#_costByPackage").val('');
			$("#_costByUnit").val('');	
			$("#_quantityOfUnits").val("<c:out value="${selectedUnit}"/>");
			$("#_quantityOfPackage").val("<c:out value="${selectedPackage}"/>");
			showFear1();
			showFear2();
	    });		
		$("input[name='_requiresPrescription']").change(function(){
			requiresPrescription();
	    }); 		
		$("#_quantityOfPackage").keyup(function(){
			if(this.value != this.value.replace(/[^0-9\.]/g, '')) {
		    	this.value = this.value.replace(/[^0-9\.]/g, '');
		    }
			var discount = $("#_discount").val();
			if (parseInt(discount,10) > 100)
				discount = $("#_discount").val(100);
			var discountPercentageTemp = discountPercentage($("#_costByPackage").val(),discount,$("#_quantityOfPackage").val());
			$("#_priceTotal").val(parseFloat(($("#_costByPackage").val())*($("#_quantityOfPackage").val())).toFixed(2));
	        $("#_priceTotalDcto").val(parseFloat(totalPrice(($("#_costByPackage").val())*($("#_quantityOfPackage").val()),discountPercentageTemp)).toFixed(2));
	        showFear1();
			showFear2();
	    }); 
		$("#_quantityOfUnits").keyup(function(){
			if(this.value != this.value.replace(/[^0-9\.]/g, '')) {
		    	this.value = this.value.replace(/[^0-9\.]/g, '');
		    }
			var discount = $("#_discount").val();
			if (parseInt(discount,10) > 100)
				discount = $("#_discount").val(100);
			var discountPercentageTemp = discountPercentage($("#_costByUnit").val(),discount,$("#_quantityOfUnits").val());			
			$("#_priceTotal").val(parseFloat(($("#_costByUnit").val())*($("#_quantityOfUnits").val())).toFixed(2));
	        $("#_priceTotalDcto").val(parseFloat(totalPrice(($("#_costByUnit").val())*($("#_quantityOfUnits").val()),discountPercentageTemp)).toFixed(2));	  
	        showFear1();
			showFear2();
	    }); 		
		$('.calculateDataByPackage').keyup(function () {
			if(this.value != this.value.replace(/[^0-9\.]/g, '')) {
		    	this.value = this.value.replace(/[^0-9\.]/g, '');
		    }			
			if($("#_quantityOfPackage").val() == 0)
				$("#_quantityOfPackage").val(1);
			
			if($("#_unitsByPackage").val() == 0)
				$("#_unitsByPackage").val(1);
			calculateDataByPackage(this.value,$("#_discount").val());
			showFear1();
			showFear2();
	    });			
		$('.calculateDataByUnit').keyup(function () {
			if(this.value != this.value.replace(/[^0-9\.]/g, '')) {
		    	this.value = this.value.replace(/[^0-9\.]/g, '');
		    }			
			if($("#_quantityOfUnits").val() == 0)
				$("#_quantityOfUnits").val(1);
			calculateDataByUnit(this.value,$("#_discount").val());
			showFear1();
			showFear2();
	    });
		$('.calculateDataByDiscount').keyup(function () {
			if(this.value != this.value.replace(/[^0-9\.]/g, '')) {
		    	this.value = this.value.replace(/[^0-9\.]/g, '');
		    }
			var discount = this.value;
			if (parseInt(discount,10) > 100){
				$("#_discount").val(100);
				discount = $("#_discount").val();
			}			
			var tipoFecha = parseInt($("input[name='_purchaseUnit']:checked").val(),10);
	        if(tipoFecha == 1){	// package
	        	var discountPercentageTemp = discountPercentage($("#_costByPackage").val(),discount,$("#_quantityOfPackage").val());
	        	$("#_priceTotal").val(parseFloat(($("#_costByPackage").val())*($("#_quantityOfPackage").val())).toFixed(2));
		        $("#_priceTotalDcto").val(parseFloat(totalPrice(($("#_costByPackage").val())*($("#_quantityOfPackage").val()),discountPercentageTemp)).toFixed(2));
	        }else{
	        	var discountPercentageTemp = discountPercentage($("#_costByUnit").val(),discount,$("#_quantityOfUnits").val());
	        	$("#_priceTotal").val(parseFloat(($("#_costByUnit").val())*($("#_quantityOfUnits").val())).toFixed(2));
		        $("#_priceTotalDcto").val(parseFloat(totalPrice(($("#_costByUnit").val())*($("#_quantityOfUnits").val()),discountPercentageTemp)).toFixed(2));
	        }			
	    });		
		$('.percentage1percentage2').keyup(function () {
			var percentage1 = $("#_percentage1").val();
			var percentage2 = $("#_percentage2").val();		
			if(parseInt(percentage1,10) > 100)
				$("#_percentage1").val(100);		
			if(parseInt(percentage2,10) > 100)
				$("#_percentage2").val(100);
	    });
		$('.numbersOnly').keyup(function () {
	        if (this.value != this.value.replace(/[^0-9\.]/g, '')) {
	           this.value = this.value.replace(/[^0-9\.]/g, '');
	        }
	    });	
		$('.numberOnlyNumber').keyup(function () {
	        if (this.value != this.value.replace(/[^0-9]/g,'')) {
	           this.value = this.value.replace(/[^0-9]/g, '');
	        }
	    });	
        $("#checkTable").click(function(){       
			if($(this).is(":checked")){
				$("input:checkbox").prop('checked', true);
	 			$("input[type=checkbox]").prop('checked', true);
	 			checkbox_1(this);
	 			checkbox_2(this);
	 		}else{
	 			$("input:checkbox").prop('checked', false);
	 			$("input[type=checkbox]").prop('checked', false);
	 			checkbox_1(this);
	 			checkbox_2(this);
	 		}
        }); 		
		$("#checkbox_1").click(function(){
			checkbox_1(this);
        });
		$("#checkbox_2").click(function(){
			checkbox_2(this);
        }); 	
		$("input[name=_fare1]").change(function () {    
			showPercentage1();
			showFear1();
		});
		$("input[name=_fare2]").change(function () {    
			showPercentage2();
			showFear2();
		});		
		$('.showFear1').keyup(function () {
			showFear1();
	    });	
		$('.showFear2').keyup(function () {
			showFear2();
	    });	
		showFear1();
		showFear2();
	});
	function showFear1(){
		var amountFixed1 = $("#_amountFixed1").val();
		var percentage1 = $("#_percentage1").val();
		if(amountFixed1 == '')
			amountFixed1 = 0.0;
		if(percentage1 == '')
			percentage1 = 0.0;		
		var cost = 0.0;		 
		var purchaseUnit = parseInt($("input[name='_purchaseUnit']:checked").val(),10);
		if(purchaseUnit == 1){
			//cost = $("#_costByPackage").val();
			cost = ($("#_costByPackage").val())*($("#_quantityOfPackage").val());		
			if($("#_costByPackage").val() == '')
				cost = 0.0;
		}else{
			//cost = $("#_costByUnit").val(); 
			cost = ($("#_costByUnit").val())*($("#_quantityOfUnits").val()); 
			if($("#_costByUnit").val() == '')
				cost = 0.0;
		}
		var total = 0.0;		
		var valueFare1 = parseInt($("input[name='_fare1']:checked").val(),10);
		if(valueFare1 == 1)
			total = parseFloat(cost)+parseFloat(amountFixed1);
		else
			total = parseFloat(cost)+parseFloat(amountFixed1)+parseFloat(((cost*percentage1)/100));
		$("#_fareTotal1").val(total.toFixed(1));
	}
	function showFear2(){
		var amountFixed2 = $("#_amountFixed2").val();
		var percentage2 = $("#_percentage2").val();
		if(amountFixed2 == '')
			amountFixed2 = 0.0;
		if(percentage2 == '')
			percentage2 = 0.0;		
		var cost = 0.0;
		var purchaseUnit = parseInt($("input[name='_purchaseUnit']:checked").val(),10);
		if(purchaseUnit == 1){
			//cost = $("#_costByPackage").val();
			cost = ($("#_costByPackage").val())*($("#_quantityOfPackage").val());			
			if($("#_costByPackage").val() == '')
				cost = 0.0;
		}else{
			//cost = $("#_costByUnit").val(); 
			cost = ($("#_costByUnit").val())*($("#_quantityOfUnits").val()); 
			if($("#_costByUnit").val() == '')
				cost = 0.0;
		}
		var total = 0.0;		
		var valueFare2 = parseInt($("input[name='_fare2']:checked").val(),10);
		if(valueFare2 == 1)
			total = parseFloat(cost)+parseFloat(amountFixed2);
		else
			total = parseFloat(cost)+parseFloat(amountFixed2)+parseFloat(((cost*percentage2)/100));
		$("#_fareTotal2").val(total.toFixed(1));
	}	
	function checkbox_1(obj){
		if($(obj).is(":checked")){
			$("#divRadioFare1").css("display", "block");
            $("#divAmountFixed1").css("display", "block");
            showPercentage1();
            $("#divFareTotal1").css("display", "block");
 		}else{
 			$("#divRadioFare1").css("display", "none");
            $("#divAmountFixed1").css("display", "none");
            $("#divPercentage1").css("display", "none"); 	
            $("#divFareTotal1").css("display", "none");
 		}
	}
	function checkbox_2(obj){
		if($(obj).is(":checked")){
			$("#divRadioFare2").css("display", "block");
            $("#divAmountFixed2").css("display", "block");
            showPercentage2();
            $("#divFareTotal2").css("display", "block");
 		}else{
 			$("#divRadioFare2").css("display", "none");
            $("#divAmountFixed2").css("display", "none");
            $("#divPercentage2").css("display", "none"); 
            $("#divFareTotal2").css("display", "none");
 		}
	}
	function showPercentage1(){
		var valueFare1 = parseInt($("input[name='_fare1']:checked").val(),10);
		if(valueFare1 == 1)
			$("#divPercentage1").css("display", "none"); 
		else
			$("#divPercentage1").css("display", "block");
	}
	function showPercentage2(){
		var valueFare2 = parseInt($("input[name='_fare2']:checked").val(),10);
		if(valueFare2 == 1)
			$("#divPercentage2").css("display", "none"); 
		else
			$("#divPercentage2").css("display", "block");
	}
	function calculateDataByUnit(value,discount){
		if (parseInt(discount,10) > 100)
			discount = $("#_discount").val(100);
		var discountPercentageTemp = discountPercentage(value,discount,$("#_quantityOfUnits").val());
		$("#_priceTotal").val(parseFloat((value)*($("#_quantityOfUnits").val())).toFixed(2));
        $("#_priceTotalDcto").val(parseFloat(totalPrice((value)*($("#_quantityOfUnits").val()),discountPercentageTemp)).toFixed(2));
	}
	function calculateDataByPackage(value,discount){
		if (parseInt(discount,10) > 100)
			discount = $("#_discount").val(100);
		var discountPercentageTemp = discountPercentage(value,discount,$("#_quantityOfPackage").val());
		$("#_priceTotal").val(parseFloat((value)*($("#_quantityOfPackage").val())).toFixed(2));
	    $("#_priceTotalDcto").val(parseFloat(totalPrice((value)*($("#_quantityOfPackage").val()),discountPercentageTemp)).toFixed(2));
	}	
	function purchaseUnit(){
		var purchaseUnitTemp = parseInt($("input[name='_purchaseUnit']:checked").val(),10);
        if(purchaseUnitTemp == 1){
            $("#typeByPackageDiv").css("display", "block");
            $("#typeByUnitDiv").css("display", "none");
        }else{
            $("#typeByPackageDiv").css("display", "none");
            $("#typeByUnitDiv").css("display", "block");
        }
	}
	function requiresPrescription(){
		var prescription = parseInt($("input[name='_requiresPrescription']:checked").val(),10);
        if(prescription == 1)
        	$("#dueDateDiv").css("display", "block");
        else
        	$("#dueDateDiv").css("display", "none");
	}	
	function discountPercentage(valueMoney,valueDiscount,n){
		var res = 0.00;
		if(valueMoney != '' && valueDiscount != ''){
			res = (((parseFloat(valueMoney)*parseFloat(valueDiscount))/100))*(n);
			res=res.toFixed(2);
		}
        return res; 
	}
	function totalPrice(cost,discount){
		var res = 0.00; 
		res = cost-discount;
		if(discount != 0)
			res=res.toFixed(2);
        return res; 
	}
</script>
<c:set var="classTemp" value="form_align35" />
<form:form method="post" id="formPharmacyProduct" commandName="pharmacyProduct">  
	<input type="hidden" name="productId_" value="${_productId}"/>
	<input type="hidden" name="providerId_" value="${_providerId}"/>
	<form:hidden path="pharmacyproductPK.pharmacyId" value="${s_UserPharmacy.pharmacy.pharmacyId}"/>                    
	<form:hidden path="pharmacyproductPK.providerId" value="${_providerId}"/>                    
	<form:hidden path="pharmacyproductPK.productId" value="${_productId}"/>                    
	<form:hidden path="package1"/>                    
	<form:hidden path="service"/>                    
	<form:hidden path="requiresPrescription"/>                    
	<form:hidden path="haveExpirationDate"/>                    
	<form:hidden path="active"/>                    
	<fieldset>		
		<legend><b><fmt:message key="title.dataGeneral"/></b></legend>
		<div style="clear:both;">
			<label class="${classTemp}"><fmt:message key="form.provider"/>:</label>
			<div id="nameProviderContainer"></div>
		</div>
		<div style="clear:both;">
			<c:set var="showRepositionLevel" scope="page"><fmt:message key="show.form.repositionLevel"/>.</c:set>																																				                             												
			<label class="${classTemp}"><fmt:message key="form.repositionLevel"/>:</label>
			<form:input path="repositionLevel" id="repositionLevel" class="required form_input_align numberOnlyNumber" maxlength="25" title="${showRepositionLevel}" autofocus="autofocus"/>
			<label class="error">*</label>		
		</div>		
		<div style="clear:both;">
			<c:set var="showSurplusLevel" scope="page"><fmt:message key="show.form.surplusLevel"/>.</c:set>																																				                             												
			<label class="${classTemp}"><fmt:message key="form.surplusLevel"/>:</label>
			<form:input path="surplusLevel" id="surplusLevel" class="form_input_align numberOnlyNumber" maxlength="25" title="${showSurplusLevel}"/>
		</div>
		<div style="clear:both;">
			<c:set var="showLocation" scope="page"><fmt:message key="show.form.location"/>.</c:set>																																				                             												
			<label class="${classTemp}"><fmt:message key="form.location"/>:</label>
		  	<form:input path="location" id="location" class="required form_input_align" title="${showLocation}"/>
			<label class="error">*</label>		
		</div>	
		<div style="clear:both;">
			<label class="${classTemp}"><fmt:message key="form.requiresPrescription"/> :</label>		
			<c:choose>
				<c:when test="${pharmacyProduct.pharmacyproductPK.productId != ''}">
					<c:choose>
						<c:when test="${pharmacyProduct.requiresPrescription}">
							<input type="radio" name="_requiresPrescription" id="requiresPrescription_1" value="1" class="required " checked="checked"/><label for="requiresPrescription_1">&nbsp;<fmt:message key="form.yes"/>&nbsp;&nbsp;</label>
			    			<input type="radio" name="_requiresPrescription" id="requiresPrescription_0" value="0" class="required " /><label for="requiresPrescription_0">&nbsp;<fmt:message key="form.no"/>&nbsp;&nbsp;</label>
						</c:when>
						<c:otherwise>
							<input type="radio" name="_requiresPrescription" id="requiresPrescription_1" value="1" class="required " /><label for="requiresPrescription_1">&nbsp;<fmt:message key="form.yes"/>&nbsp;&nbsp;</label>
			    			<input type="radio" name="_requiresPrescription" id="requiresPrescription_0" value="0" class="required " checked="checked"/><label for="requiresPrescription_0">&nbsp;<fmt:message key="form.no"/>&nbsp;&nbsp;</label>
						</c:otherwise>
					</c:choose>
				</c:when>
				<c:otherwise>
					<input type="radio" name="_requiresPrescription" id="requiresPrescription_1" value="1" class="required " checked="checked"/><label for="requiresPrescription_1">&nbsp;<fmt:message key="form.yes"/>&nbsp;&nbsp;</label>
		    		<input type="radio" name="_requiresPrescription" id="requiresPrescription_0" value="0" class="required " /><label for="requiresPrescription_0">&nbsp;<fmt:message key="form.no"/>&nbsp;&nbsp;</label>
				</c:otherwise>
			</c:choose>
		</div>				
	</fieldset>	
	<fieldset>		
		<legend><b><fmt:message key="title.dataSpecific"/></b></legend>
		<div style="clear: both;">
			<label class="${classTemp}"><fmt:message key="form.stock"/> :</label>			
			<select name="_stock" id="_stock">
				<c:forEach var="item" items="${listPharmacyStock}">
					<c:set var="selec" value="" />
					<c:if test="${pharmacyProduct.pharmacyproductPK.productId != ''}">
						<c:if test="${item.pharmacystockPK.stockId == pharmacyProduct.valueTempStockId}">
							<c:set var="selec" value="selected='selected'" />
						</c:if>
					</c:if>
				  	<option value="${item.pharmacystockPK.stockId}" ${selec}>${item.stock.name}</option>
				</c:forEach>
			</select>
		</div>	
		
		
		<div style="clear:both;">
			<c:set var="showBatchNumber" scope="page"><fmt:message key="show.form.batchNumber"/>.</c:set>		
			<label class="${classTemp}"><fmt:message key="form.batchNumber"/> :</label>
			<input type="text" name="_batchNumber" id="_batchNumber"  value="${packageTemp.batchNumber}" class="required form_input_align numberOnlyNumber" title="${showBatchNumber}"/>
			<label class="error">*</label>		
		</div>
		
		<div style="clear:both;">
			<label class="${classTemp}"><fmt:message key="form.purchaseUnit"/> :</label>	
			<c:choose>
				<c:when test="${pharmacyProduct.pharmacyproductPK.productId != ''}">
					<c:choose>
						<c:when test="${pharmacyProduct.package1}">
							<input type="radio" name="_purchaseUnit" id="_purchaseUnit_1" value="1" class="required " checked="checked" /><label for="_purchaseUnit_1">&nbsp;&nbsp;<fmt:message key="form.byPackage"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
		    				<input type="radio" name="_purchaseUnit" id="_purchaseUnit_0" value="0" class="required " /><label for="_purchaseUnit_0">&nbsp;&nbsp;<fmt:message key="form.byUnit"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
						</c:when>
						<c:otherwise>
							<input type="radio" name="_purchaseUnit" id="_purchaseUnit_1" value="1" class="required " /><label for="_purchaseUnit_1">&nbsp;&nbsp;<fmt:message key="form.byPackage"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
		    				<input type="radio" name="_purchaseUnit" id="_purchaseUnit_0" value="0" class="required " checked="checked" /><label for="_purchaseUnit_0">&nbsp;&nbsp;<fmt:message key="form.byUnit"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
						</c:otherwise>
					</c:choose>
				</c:when>
				<c:otherwise>
					<input type="radio" name="_purchaseUnit" id="_purchaseUnit_1" value="1" class="required " checked="checked" /><label for="_purchaseUnit_1">&nbsp;&nbsp;<fmt:message key="form.byPackage"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
		    		<input type="radio" name="_purchaseUnit" id="_purchaseUnit_0" value="0" class="required " /><label for="_purchaseUnit_0">&nbsp;&nbsp;<fmt:message key="form.byUnit"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
				</c:otherwise>
			</c:choose>				
		</div>
		
		<div id="typeByPackageDiv" style="clear: both;">
			<div style="clear: both;">				
				<c:set var="showQuantityOfPackage" scope="page"><fmt:message key="show.form.quantityOfPackage"/>.</c:set>		
				<label class="${classTemp}"><fmt:message key="form.quantityOfPackage"/> :</label>
				<input type="text" name="_quantityOfPackage" id="_quantityOfPackage"  value="${pharmacyProduct.valueTempCountPackage}" class="required form_input_align numberOnlyNumber" title="${showQuantityOfPackage}"/>
				<label class="error">*</label>	
			</div>
			<div style="clear: both;">				
				<c:set var="showUnitsByPackage" scope="page"><fmt:message key="show.form.unitsByPackage"/>.</c:set>		
				<label class="${classTemp}"><fmt:message key="form.unitsByPackage"/> :</label>
				<input type="text" name="_unitsByPackage" id="_unitsByPackage"  value="${pharmacyProduct.valueTempCountItem}" class="required form_input_align numberOnlyNumber" title="${showUnitsByPackage}"/>
				<label class="error">*</label>	
			</div>					
			<div style="clear:both;">
				<c:set var="showCostByPackage" scope="page"><fmt:message key="show.form.costByPackage"/>.</c:set>		
				<label class="${classTemp}"><fmt:message key="form.costByPackage"/> :</label>
				<input type="text" name="_costByPackage" id="_costByPackage" value="${pharmacyProduct.cost}" class="required form_input_align calculateDataByPackage" title="${showCostByPackage}"/>
				<label class="error">*</label>		
			</div>
		</div>
		<div id="typeByUnitDiv" style="clear: both; display: none;">
			<div style="clear: both;">				
				<c:set var="showQuantityOfUnits" scope="page"><fmt:message key="show.form.quantityOfUnits"/>.</c:set>		
				<label class="${classTemp}"><fmt:message key="form.quantityOfUnits"/> :</label>
				<input type="text" name="_quantityOfUnits" id="_quantityOfUnits"  value="${pharmacyProduct.valueTempCountItem}" class="required form_input_align numberOnlyNumber" title="${showQuantityOfUnits}"/>
				<label class="error">*</label>	
			</div>				
			<div style="clear:both;">
				<c:set var="showCostByUnit" scope="page"><fmt:message key="show.form.costByUnit"/>.</c:set>		
				<label class="${classTemp}"><fmt:message key="form.costByUnit"/> :</label>
				<input type="text" name="_costByUnit" id="_costByUnit" value="${pharmacyProduct.cost}" class="required form_input_align calculateDataByUnit" title="${showCostByUnit}"/>
				<label class="error">*</label>		
			</div>
		</div>
		
		<div style="clear:both;">
			<c:set var="showBonus" scope="page"><fmt:message key="show.form.bonus"/>.</c:set>		
			<label class="${classTemp}"><fmt:message key="form.bonus"/> :</label>
			<c:choose>
				<c:when test="${pharmacyProduct.pharmacyproductPK.productId != '' && pharmacyProduct.packageCollection.size() > 0}">
					<input type="text" name="_bonus" id="_bonus" value="${pharmacyProduct.valueBonus}" class="form_input_align numberOnlyNumber" title="${showBonus}"/>
				</c:when>
				<c:otherwise>
					<input type="text" name="_bonus" id="_bonus" value="0" class="form_input_align numberOnlyNumber" title="${showBonus}"/>
				</c:otherwise>
			</c:choose>
			<label>(<fmt:message key="title.units"/>)</label>
		</div>
		
		<div style="clear:both;">
			<c:set var="showDiscount" scope="page"><fmt:message key="form.discount"/>.</c:set>		
			<label class="${classTemp}"><fmt:message key="form.discount"/> :</label>
			<c:choose>
				<c:when test="${pharmacyProduct.pharmacyproductPK.productId != '' && pharmacyProduct.packageCollection.size() > 0}">
					<input type="text" name="_discount" id="_discount" value="${pharmacyProduct.valueDiscount}" class="form_input_align calculateDataByDiscount" title="${showDiscount}"/>
				</c:when>
				<c:otherwise>
					<input type="text" name="_discount" id="_discount" value="0" class="form_input_align calculateDataByDiscount" title="${showDiscount}"/>
				</c:otherwise>
			</c:choose>	
			<label>(%)</label>
		</div>
		<div style="clear:both;">
			<c:set var="showPriceTotal" scope="page"><fmt:message key="form.priceTotal"/>.</c:set>		
			<label class="${classTemp}"><fmt:message key="form.priceTotal"/> :</label>
			<input type="text" name="_priceTotal" id="_priceTotal" value="${tempPriceTotal}" class="form_input_align" title="${showPriceTotal}"/>
			<label><fmt:message key="title.sigleMoney"/></label>
		</div>
		<div style="clear:both;">
			<c:set var="showPriceTotalDcto" scope="page"><fmt:message key="form.priceTotalDcto"/>.</c:set>		
			<label class="${classTemp}"><fmt:message key="form.priceTotalDcto"/> :</label>
			<input type="text" name="_priceTotalDcto" id="_priceTotalDcto" value="${tempPriceTotalDcto}" class="form_input_align" title="${showPriceTotalDcto}"/>
			<label><fmt:message key="title.sigleMoney"/></label>
		</div>
		<div id="dueDateDiv" style="clear: both;">
			<div style="clear:both;">
				<c:set var="showDueDate" scope="page"><fmt:message key="show.form.dueDate"/>.</c:set>		
				<label class="${classTemp}" for="_dueDate"><fmt:message key="form.dueDate"/> :</label>	
				<c:set var="tempDueDate" value="" />	
                <c:if test="${pharmacyProduct.pharmacyproductPK.productId != '' && pharmacyProduct.packageCollection.size() > 0}">
                	<c:set var="partsDueDate" value="${fn:split(packageTemp.dueDate,'-')}" />
                	<c:set var="tempDueDate" value="${partsDueDate[2]}/${partsDueDate[1]}/${partsDueDate[0]}" />
                </c:if>
				<input type="text" name="_dueDate" id="_dueDate" class="required" title="${showDueDate}" value="${tempDueDate}" style="border:1px solid #959595; margin-left:0.2em;" readonly="true" onclick="$(this).datepicker({changeMonth: true,changeYear: true,numberOfMonths: 1});$(this).datepicker().datepicker('show');">
				<label class="error">*</label>	
			</div>
		</div>
				
		<div style="clear:both;">
			<c:set var="showAddValue" scope="page"><fmt:message key="show.fomr.addValue"/>.</c:set>		
			<table class="tabla_decorado" style="width: 100%">
			<thead>
				<tr>
					<th width="10%" class="th_decoradoRowspan"><input type="checkbox" id="checkTable" /><label for="checkTable">&nbsp;<fmt:message key="table.providers"/></label></th>
					<th width="20%" class="th_decoradoRowspan"><fmt:message key="table.fare"/></th>
					<th width="10%" class="th_decoradoRowspan"><fmt:message key="table.amountFixed"/></th>
					<th width="10%" class="th_decoradoRowspan"><fmt:message key="table.percentage"/></th>
					<th width="10%" class="th_decoradoRowspan"><fmt:message key="table.total"/></th>
				</tr>
			</thead>
			<tbody>
				<tr class="tr_decorado">
					<td class="th_decorado" style="text-align: center"><input type="checkbox" id="checkbox_1" name="checkbox_1" ${(packageTemp.tempUniquePrice1)?'checked':''}/><label for="checkbox_1"><fmt:message key="form.retail"/></label></td>
					<td class="th_decorado" style="text-align: center">
						<div id = "divRadioFare1" style="clear: both; display: none;">
							<c:choose>
								<c:when test="${pharmacyProduct.pharmacyproductPK.productId != '' && packageTemp.packageId != ''}">
									<c:choose>
										<c:when test="${packageTemp.tempUniquePrice1}">
											<c:choose>
												<c:when test="${packageTemp.uniquePrice1}">
													<input type="radio" name="_fare1" id="_fare1_1" value="1" class="required " checked="checked" title="<fmt:message key="show.form.selected.fare"/>"/><label for="_fare1_1">&nbsp;<fmt:message key="form.singleFare"/>&nbsp;&nbsp;</label>
					    							<input type="radio" name="_fare1" id="_fare1_0" value="0" class="required " title="<fmt:message key="show.form.selected.fare"/>"/><label for="_fare1_0">&nbsp;<fmt:message key="form.baseFare"/>&nbsp;&nbsp;</label>
												</c:when>
												<c:otherwise>
													<input type="radio" name="_fare1" id="_fare1_1" value="1" class="required " title="<fmt:message key="show.form.selected.fare"/>"/><label for="_fare1_1">&nbsp;<fmt:message key="form.singleFare"/>&nbsp;&nbsp;</label>
					    							<input type="radio" name="_fare1" id="_fare1_0" value="0" class="required " checked="checked" title="<fmt:message key="show.form.selected.fare"/>"/><label for="_fare1_0">&nbsp;<fmt:message key="form.baseFare"/>&nbsp;&nbsp;</label>
												</c:otherwise>
											</c:choose>
										</c:when>
										<c:otherwise>
											<input type="radio" name="_fare1" id="_fare1_1" value="1" class="required " title="<fmt:message key="show.form.selected.fare"/>"/><label for="_fare1_1">&nbsp;<fmt:message key="form.singleFare"/>&nbsp;&nbsp;</label>
					    					<input type="radio" name="_fare1" id="_fare1_0" value="0" class="required " title="<fmt:message key="show.form.selected.fare"/>"/><label for="_fare1_0">&nbsp;<fmt:message key="form.baseFare"/>&nbsp;&nbsp;</label>
										</c:otherwise>
									</c:choose>
								</c:when>
								<c:otherwise>
									<input type="radio" name="_fare1" id="_fare1_1" value="1" class="required " title="<fmt:message key="show.form.selected.fare"/>" /><label for="_fare1_1">&nbsp;<fmt:message key="form.singleFare"/>&nbsp;&nbsp;</label>
					    			<input type="radio" name="_fare1" id="_fare1_0" value="0" class="required " checked="checked" title="<fmt:message key="show.form.selected.fare"/>" /><label for="_fare1_0">&nbsp;<fmt:message key="form.baseFare"/>&nbsp;&nbsp;</label>
								</c:otherwise>
							</c:choose>
						</div>
					</td>
					<td class="th_decorado" style="text-align: center">
						<div id = "divAmountFixed1" style="clear: both; display: none;">
							<c:choose>
								<c:when test="${pharmacyProduct.pharmacyproductPK.productId != '' && packageTemp.packageId != ''}">
									<input type="text" name="_amountFixed1" id="_amountFixed1" value="${packageTemp.amountFixe1}" class="required numbersOnly showFear1" style="border:1px solid #959595; margin-left:0.2em; width:40px" title="${showAddValue}"/> <fmt:message key="title.sigleMoney"/>
								</c:when>
								<c:otherwise>
									<input type="text" name="_amountFixed1" id="_amountFixed1" value="0" class="required numbersOnly showFear1" style="border:1px solid #959595; margin-left:0.2em; width:40px" title="${showAddValue}"/> <fmt:message key="title.sigleMoney"/>
								</c:otherwise>
							</c:choose>
						</div>
					</td>
					<td class="th_decorado" style="text-align: center">
						<div id = "divPercentage1" style="clear: both; display: none;">
							<c:choose>
								<c:when test="${pharmacyProduct.pharmacyproductPK.productId != '' && packageTemp.packageId != ''}">
									<input type="text" name="_percentage1" id="_percentage1" value="${packageTemp.percentage1}" class="required numbersOnly showFear1 percentage1percentage2" style="border:1px solid #959595; margin-left:0.2em; width:40px" title="${showAddValue}"/> %
								</c:when>
								<c:otherwise>
									<input type="text" name="_percentage1" id="_percentage1" value="0" class="required numbersOnly showFear1 percentage1percentage2" style="border:1px solid #959595; margin-left:0.2em; width:40px" title="${showAddValue}"/> %
								</c:otherwise>
							</c:choose>
						</div>
					</td>
					<td class="th_decorado" style="text-align: center">
						<div id = "divFareTotal1" style="clear: both; display: none;">
							<c:choose>
								<c:when test="${pharmacyProduct.pharmacyproductPK.productId != '' && packageTemp.packageId != ''}">
									<c:set var="tempTotal" value="${packageTemp.tempTotal1}" />	
									<input type="text" name="_fareTotal1" id="_fareTotal1" value="${tempTotal}" class="required numbersOnly " style="border:1px solid #959595; margin-left:0.2em; width:40px"/>
								</c:when>
								<c:otherwise>
									<input type="text" name="_fareTotal1" id="_fareTotal1" value="0" class="required numbersOnly " style="border:1px solid #959595; margin-left:0.2em; width:40px"/>
								</c:otherwise>
							</c:choose>
						</div>
					</td>
				</tr>				
				<tr class="tr_decorado">
					<td class="th_decorado" style="text-align: center"><input type="checkbox" id="checkbox_2" name="checkbox_2" ${(packageTemp.tempUniquePrice2)?'checked':''}/><label for="checkbox_2"><fmt:message key="form.wholesale"/></label></td>
					<td class="th_decorado" style="text-align: center">
						<div id = "divRadioFare2" style="clear: both; display: none;">
							<c:choose>
								<c:when test="${pharmacyProduct.pharmacyproductPK.productId != '' && packageTemp.packageId != ''}">
									<c:choose>
										<c:when test="${packageTemp.tempUniquePrice2}">
											<c:choose>
												<c:when test="${packageTemp.uniquePrice2}">
													<input type="radio" name="_fare2" id="_fare2_1" value="1" class="required " checked="checked" title="<fmt:message key="show.form.selected.fare"/>"/><label for="_fare2_1">&nbsp;<fmt:message key="form.singleFare"/>&nbsp;&nbsp;</label>
									    			<input type="radio" name="_fare2" id="_fare2_0" value="0" class="required " title="<fmt:message key="show.form.selected.fare"/>"/><label for="_fare2_0">&nbsp;<fmt:message key="form.baseFare"/>&nbsp;&nbsp;</label>
												</c:when>
												<c:otherwise>
													<input type="radio" name="_fare2" id="_fare2_1" value="1" class="required " title="<fmt:message key="show.form.selected.fare"/>"/><label for="_fare2_1">&nbsp;<fmt:message key="form.singleFare"/>&nbsp;&nbsp;</label>
									    			<input type="radio" name="_fare2" id="_fare2_0" value="0" class="required " checked="checked" title="<fmt:message key="show.form.selected.fare"/>"/><label for="_fare2_0">&nbsp;<fmt:message key="form.baseFare"/>&nbsp;&nbsp;</label>
												</c:otherwise>
											</c:choose>
										</c:when>
										<c:otherwise>
											<input type="radio" name="_fare2" id="_fare2_1" value="1" class="required " title="<fmt:message key="show.form.selected.fare"/>"/><label for="_fare2_1">&nbsp;<fmt:message key="form.singleFare"/>&nbsp;&nbsp;</label>
							    			<input type="radio" name="_fare2" id="_fare2_0" value="0" class="required " title="<fmt:message key="show.form.selected.fare"/>"/><label for="_fare2_0">&nbsp;<fmt:message key="form.baseFare"/>&nbsp;&nbsp;</label>
										</c:otherwise>
									</c:choose>
								</c:when>																					
								<c:otherwise>
									<input type="radio" name="_fare2" id="_fare2_1" value="1" class="required " title="<fmt:message key="show.form.selected.fare"/>" /><label for="_fare2_1">&nbsp;<fmt:message key="form.singleFare"/>&nbsp;&nbsp;</label>
					    			<input type="radio" name="_fare2" id="_fare2_0" value="0" class="required " checked="checked" title="<fmt:message key="show.form.selected.fare"/>"/><label for="_fare2_0">&nbsp;<fmt:message key="form.baseFare"/>&nbsp;&nbsp;</label>
								</c:otherwise>
							</c:choose>
						</div>
					</td>
					<td class="th_decorado" style="text-align: center">
						<div id = "divAmountFixed2" style="clear: both; display: none;">
							<c:choose>
								<c:when test="${pharmacyProduct.pharmacyproductPK.productId != '' && packageTemp.packageId != ''}">
									<input type="text" name="_amountFixed2" id="_amountFixed2" value="${packageTemp.amountFixe2}" class="required numbersOnly showFear2" style="border:1px solid #959595; margin-left:0.2em; width:40px" title="${showAddValue}"/> <fmt:message key="title.sigleMoney"/>
								</c:when>
								<c:otherwise>
									<input type="text" name="_amountFixed2" id="_amountFixed2" value="0" class="required numbersOnly showFear2" style="border:1px solid #959595; margin-left:0.2em; width:40px" title="${showAddValue}"/> <fmt:message key="title.sigleMoney"/>
								</c:otherwise>
							</c:choose>
						</div>
					</td>
					<td class="th_decorado" style="text-align: center">
						<div id = "divPercentage2" style="clear: both; display: none;">
							<c:choose>
								<c:when test="${pharmacyProduct.pharmacyproductPK.productId != '' && packageTemp.packageId != ''}">
									<input type="text" name="_percentage2" id="_percentage2" value="${packageTemp.percentage2}" class="required numbersOnly percentage1percentage2 showFear2" style="border:1px solid #959595; margin-left:0.2em; width:40px" title="${showAddValue}"/> %
								</c:when>
								<c:otherwise>
									<input type="text" name="_percentage2" id="_percentage2" value="0" class="required numbersOnly percentage1percentage2 showFear2" style="border:1px solid #959595; margin-left:0.2em; width:40px" title="${showAddValue}"/> %
								</c:otherwise>
							</c:choose>
						</div>
					</td>
					<td class="th_decorado" style="text-align: center">
						<div id = "divFareTotal2" style="clear: both; display: none;">
							<c:choose>
								<c:when test="${pharmacyProduct.pharmacyproductPK.productId != '' && packageTemp.packageId != ''}">
									<c:set var="tempTotal" value="${packageTemp.tempTotal2}" />	
									<input type="text" name="_fareTotal2" id="_fareTotal2" value="${tempTotal}" class="required numbersOnly" style="border:1px solid #959595; margin-left:0.2em; width:40px"/>
								</c:when>
								<c:otherwise>
									<input type="text" name="_fareTotal2" id="_fareTotal2" value="0" class="required numbersOnly" style="border:1px solid #959595; margin-left:0.2em; width:40px"/>
								</c:otherwise>
							</c:choose>
						</div>
					</td>
				</tr>
			</tbody>
		</table>
		</div>
	</fieldset>	
</form:form>



